# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-menhir
_pkgname=menhir
# NOTE: Check supported version in Reason before upgrading!
pkgver=20220210
_commit=4f8151679e73cdfe598c42220ae869f904dfaa9a
pkgrel=0
pkgdesc="LR(1) parser generator for OCaml"
url="http://gallium.inria.fr/~fpottier/menhir/"
arch="all !riscv64"  # limited by ocaml aport
license="GPL-2.0-only"
depends="ocaml-findlib"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-runtime"
makedepends="dune ocaml ocaml-ocamlbuild-dev ocamlbuild"
options="!check"  # no tests provided
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://gitlab.inria.fr/fpottier/menhir/-/archive/$pkgver/archive.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver-$_commit"

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	export OCAMLPATH=/usr/lib/ocaml
	dune build --root . @install --no-buffer --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--prefix=/usr \
		--libdir=/usr/lib/ocaml

	mkdir -vp "$pkgdir"/usr/share
	mv -v "$pkgdir"/usr/man "$pkgdir"/usr/share/
}

dev() {
	pkgdesc="$pkgdesc (development files)"
	license="LGPL-2.0-only-WITH-linking-exception"

	amove usr/lib/ocaml
}

sha512sums="
3063fec1d8b9fe092c8461b0689d426c7fe381a2bf3fd258dc42ceecca1719d32efbb8a18d94ada5555c38175ea352da3adbb239fdbcbcf52c3a5c85a4d9586f  ocaml-menhir-20220210.tar.gz
"
